<%@page language="java" import="OnlineExam.*, validate.*"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Category Administrator Control Panel</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>

<jsp:include page="common/header.jsp"/>

<center><b>The Contents Of The Question Bank</b></center><br>
<%@page language="java" import="OnlineExam.category.*, OnlineExam.question.*, java.util.*"%>
<%
	Category cat = (Category) session.getAttribute ("CATEGORY");
	
	//retrieves questions belonging to a particular category.
	//
	List<Question> list = cat.retrieveQuestions();
%>
<center>Category : <%= cat.getCategoryId() %></center><br />
<table border = "1" align ="center">
<thead><tr><TH>Action</TH><TH>Question</TH><TH>Options</TH><TH>CorrectAnswer</TH><TH>Explanation</TH><TH>CorrectMarks</TH><TH>WrongMarks</TH></tr></thead>
 
<%			 
	for (ListIterator iter = list.listIterator (); iter.hasNext();)
	{
		Question q = (Question) iter.next();
%>
	
<tr> 
<td><FORM><center>

<INPUT type="button" value="Edit" onClick="window.open('http://<%= request.getServerName()%>/OnlineExam/jsp/ModifyQuestion.jsp?questionNumber=<%= q.getNumber()%>','mywindow','width=700,height=2000')"></center></form><br />

<center><form><input type="button" value="Delete" onClick="window.open('http://<%=request.getServerName()%>/OnlineExam/jsp/DeleteQuestion.jsp?questionNumber=<%=q.getNumber()%>','mywindow2','width=500,height=200')"></FORM></center></td>
     <td> <%= q.getQuestion() %></td>
	 <td> 
	 
<%
		String answers[] = q.splitOptions();
		
		for (int i = 0; i < answers.length; i++)
		{
%>			<%=(i+1)%>--><%=answers[i]%><br /><br/>

<%
		}
		
%>
	 </td>
     <td> <%= "A"+q.getCorrectAnswer()%></td>
     <td> <%= q.getExplanation() %></td>
     <td> <%= q.getCorrectMarks() %></td>
     <td> <%= q.getWrongMarks() %></td>
</tr>			            
				    
<%	
	} 	
%>
</table>
<br /><br />
<center><table><tr>
<form action="QuestionViewer.jsp" method="get">
<td><input type="Submit" value="Refresh"></td>
</form>
<form action="CategoryAdmin.jsp" method="get">
<td><center><input type="Submit" value="OK">
</td></form>
</tr></table></center>
<jsp:include page="common/footer.jsp"/>
</body>
</html>
